# Contributor: Diaz Devera Victor <vitronic2@gmail.com>
# Maintainer: Bart Ribbers <bribbers@disroot.org>
pkgname=qt5-qtgamepad
pkgver=5.15.5_git20220516
pkgrel=0
_commit="5107ddf28177112cdbf505f92bb4191a91e6521a"
pkgdesc="Adds support for getting events from gamepad devices"
url="https://doc.qt.io/qt-5/qtgamepad-index.html"
license="LGPL-2.1-only AND LGPL-3.0-only AND GPL-3.0-only AND Qt-GPL-exception-1.0"
arch="all !armhf" # armhf blocked by qt5-qtdeclarative
depends_dev="
	eudev-dev
	qt5-qtdeclarative-dev
	sdl2-dev
	"
makedepends="$depends_dev
	qt5-qtbase-dev
	"
subpackages="$pkgname-dev"
builddir="$srcdir/qtgamepad-$_commit"

case $pkgver in
	*_beta*|*_rc*) _rel=development_releases;;
	*) _rel=official_releases;;
esac

source="https://invent.kde.org/qt/qt/qtgamepad/-/archive/$_commit/qtgamepad-$_commit.tar.gz"

prepare() {
	default_prepare

	# We need to make the build system think we're running in a git repository
	# so it correctly symlinks during the build
	mkdir .git
}

build() {
	qmake-qt5
	make -j1
}

check() {
	make check
}

package() {
	make INSTALL_ROOT="$pkgdir" install

	# Drop QMAKE_PRL_BUILD_DIR because reference the build dir
	find "$pkgdir/usr/lib" -type f -name '*.prl' \
		-exec sed -i -e '/^QMAKE_PRL_BUILD_DIR/d' {} \;

	install -d "$pkgdir"/usr/share/licenses
	ln -s /usr/share/licenses/qt5-base "$pkgdir"/usr/share/licenses/$pkgname
}

sha512sums="
66c2f969f27f0c762179bbe1cfe21be9f744c8e544a6fa81d9b11a00764d27a36627b080b276d4921dc5eb949a98ffa4f05fb0da319b5a2259a411310811d01b  qtgamepad-5107ddf28177112cdbf505f92bb4191a91e6521a.tar.gz
"
